<?php
/**
 * | ---------------------------------------------------------------------------------------------------
 * | Author：johnxu <fsyzxz@163.com>.
 * | ---------------------------------------------------------------------------------------------------
 * | Home: https://www.johnxu.net.
 * | ---------------------------------------------------------------------------------------------------
 * | Data: 2019-03-16
 * | ---------------------------------------------------------------------------------------------------
 * | Desc:
 * | ---------------------------------------------------------------------------------------------------
 */

namespace app\admin\model;

use johnxu\tool\Str;
use think\Model;

class Group extends Model
{
    protected $name = 'group';

    protected $insert = [ 'unique_id' ];

    public function setUniqueIdAttr()
    {
        return 'g' . strtolower( Str::instance()->getMachineCode( 1, 16 ) );
    }

    public function scopeNormal( $query )
    {
        $query->where( 'status', 'normal' );
    }
}